home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / IO Examples / Scrabble / board.dcl next >
Encoding:
Modula Definition  |  1997-05-14  |  3.4 KB  |  67 lines  |  [TEXT/3PRM]

  1. definition module board
  2.  
  3.  
  4. from    StdString    import    String
  5. import    StdClass, StdFile
  6. import    types
  7.  
  8.  
  9. ::    Board                :==    (![[Char]],![[Char]])
  10.  
  11. initboard                :: Board
  12. getplacedletters        :: !Board -> [Char]
  13.  
  14. doubleletterpositions    :: [Position]
  15. tripleletterpositions    :: [Position]
  16. doublewordpositions        :: [Position]
  17. triplewordpositions        :: [Position]
  18.  
  19. grab                    :: ![Char] !Int [Int]    -> (![Char],![Char],[Int])
  20. lettervalueat            :: !Char    !Position    -> Int
  21. wordvalueat                ::            !Position    -> Int
  22.  
  23. /***************************************************************************************************************
  24.     getfreehorpositions board letter determines the positions on board that are valid horizontal starting 
  25.     positions for a word starting with letter. 
  26.     This function is useful only for letters that are not available on the letter bar of the computer player.
  27. ****************************************************************************************************************/
  28. getfreehorpositions        :: !Board !Char -> [Position]
  29.  
  30.  
  31. /***************************************************************************************************************
  32.     getfreeverpositions board letter determines the positions on board that are valid vertical starting 
  33.     positions for a word starting with letter.
  34.     This function is useful only for letters that are not available on the letter bar of the computer player.
  35. ****************************************************************************************************************/
  36. getfreeverpositions        :: !Board !Char -> [Position]
  37.  
  38.  
  39. /***************************************************************************************************************
  40.     tryaddword board word position direction adds word at position in direction to board. 
  41.     The Board    result is the new board.
  42.     The Boolean    result reports whether the word could be placed.
  43.     The [Char]    result are the letters that have been used.
  44.     The Int        result is the score by placing this word.
  45.     The Words    result are the possibly new formed words.
  46.     
  47.     After tryaddword it should be verified if the new formed words are legal. 
  48.     After tryaddword it also should be verified if a bonus should be added to the score in case all letters have 
  49.     been used.
  50. ****************************************************************************************************************/
  51. tryaddword            :: !Board !Word !Position !Direction -> (!Board,!Bool,[Char],Int,[Word])
  52.  
  53.  
  54. /***************************************************************************************************************
  55.     newmaximumplacings _ lexicon letterbar _ (Letter l _) _ _ determines all valid words from lexicon that start 
  56.     with l and are member of letterbar.
  57. ****************************************************************************************************************/
  58. newmaximumplacings    :: !Board Tree [Char] !(!Int,!Int,!Int,!Int) !Progress !Strength Bool -> Placing
  59.  
  60.  
  61. /***************************************************************************************************************
  62.     newmaximumplacing board lexicon letterbar (hor,ver) (Letter l _) _ _ determines all valid words from lexicon 
  63.     that start with l and are not member of letterbar. The positions hor++ver are assumed to be valid free 
  64.     positions on board starting with l.
  65. ****************************************************************************************************************/
  66. newmaximumplacing    :: !Board Tree [Char] ([Position],[Position]) !Progress !Strength Bool -> Placing
  67.